home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / grafica / ghostscript / 5.10 / data / uninfo.ps < prev    next >
Text File  |  1997-05-13  |  6KB  |  222 lines

  1. %!
  2. % Copyright (C) 1997 Aladdin Enterprises.  All rights reserved
  3. %
  4. % This file is part of Aladdin Ghostscript.
  5. %
  6. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  7. % or distributor accepts any responsibility for the consequences of using it,
  8. % or for whether it serves any particular purpose or works at all, unless he
  9. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  10. % License (the "License") for full details.
  11. %
  12. % Every copy of Aladdin Ghostscript must include a copy of the License,
  13. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  14. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  15. % under certain conditions described in the License.  Among other things, the
  16. % License requires that the copyright notice and this notice be preserved on
  17. % all copies.
  18.  
  19. % uninfo.ps: Utilities for "printing" PostScript items, especially dictionaries
  20. % Usage:
  21. % (prefix-string) dict unprint
  22.  
  23. % Maximum Print-Width
  24. /HSpwidth 80 def
  25.  
  26. % any  HScvs string
  27. /HScvs {
  28. % Number-Syntax
  29.   dup type % stack: any /anytype
  30.   dup /integertype eq 1 index /realtype eq or { pop
  31.     16 string cvs
  32.   }{
  33. % Logical-Type
  34.     dup /booleantype eq { pop
  35.       5 string cvs
  36.     }{
  37. % Identifiers
  38.       dup /nametype eq { pop
  39.         dup length 1 add string
  40.         dup 0 (/) putinterval
  41.         exch 1 index 1 1 index length 1 sub getinterval cvs pop
  42.       }{
  43. % Strings
  44.         dup /stringtype eq { pop
  45. % ------- Compute Length
  46.           2 1 index { % stack: str len item
  47.             dup 32 lt 1 index 126 gt or { % need 4
  48.               pop 4 add
  49.             }{
  50.               dup 40 eq 1 index 41 eq or 1 index 92 eq or {
  51.                 pop 2 add
  52.               }{
  53.                 pop 1 add
  54.               } ifelse
  55.             } ifelse
  56.           } forall
  57. % ------- Allocate & Fill String
  58.           string dup 0 (\() putinterval 1
  59.           3 -1 roll { % outstr pos item
  60.             dup 32 lt 1 index 126 gt or {
  61.               dup 7 le {
  62.                 2 index 2 index (\\00) putinterval
  63.                 8 3 index 3 index 3 add 1 getinterval cvrs
  64.               }{
  65.                 dup 63 le {
  66.                   2 index 2 index (\\0) putinterval
  67.                   8 3 index 3 index 2 add 2 getinterval cvrs
  68.                 }{
  69.                   2 index 2 index (\\) putinterval
  70.                   8 3 index 3 index 1 add 3 getinterval cvrs
  71.                 } ifelse
  72.               } ifelse
  73.               pop 4 add
  74.             }{
  75.               dup 40 eq 1 index 41 eq or 1 index 92 eq or {
  76.                 2 index 2 index (\\) putinterval
  77.                 exch 1 add exch
  78.               } if
  79.               2 index exch 2 index exch put
  80.               1 add
  81.             } ifelse 
  82.           } forall
  83.           1 index exch (\)) putinterval
  84.         }{ exch pop
  85.           dup length 1 add string
  86.           dup 0 (-) putinterval
  87.           exch 1 index 1 1 index length 1 sub getinterval cvs pop
  88.           dup dup length 4 sub (-) putinterval
  89.           0 1 index length 3 sub getinterval
  90.         } ifelse
  91.       } ifelse
  92.     } ifelse
  93.   } ifelse
  94. } bind def
  95.  
  96. % int HSpindent - indent-spaces
  97. /HSpindent {
  98.   dup 0 gt {
  99.     1 1 3 -1 roll { pop ( ) print } for
  100.   }{
  101.     pop
  102.   } ifelse
  103. } bind def
  104.  
  105. % indent array HSaprint -> Print an Array
  106. /HSaprint {
  107.   dup type /arraytype eq {
  108.     ( [) print
  109.     exch 1 add dup 1 add
  110.     3 -1 roll { % rind pos item
  111.       HScvs dup length % rind pos str len
  112.       dup 3 index add HSpwidth ge {
  113.         (\n) print
  114.         3 index HSpindent
  115.         3 -1 roll pop
  116.         2 index add
  117.         exch
  118.       }{
  119.         ( ) print
  120.         2 index add 1 add 
  121.         3 -1 roll pop
  122.         exch
  123.       } ifelse
  124.       print
  125.     } forall
  126.     ( ]) print
  127.     pop pop
  128.   }{
  129.     ( ) print
  130.     HScvs print pop
  131.   } ifelse
  132.   (\n) print
  133. } bind def
  134.  
  135. % dict HSdnames dict names (creates sorted name-strings)
  136. /HSdnames {
  137. % Build namelist, stack: dic
  138.   dup length 0 eq {
  139.     []
  140.   }{
  141.     [ 1 index {
  142.         pop dup type /nametype eq {
  143.           dup length string cvs
  144.         }{ 
  145.           pop
  146.         } ifelse
  147.       } forall
  148.     ]
  149. % Sort the namelist, stack: dic nam
  150.     0 1 2 index length 2 sub { % stack: dic nam I
  151.       2 copy get % stack: pre dic nam I nam[I]
  152.       1 index 1 add 1 4 index length 1 sub { % stack: dic nam I nam[I] J
  153.         3 index 1 index get % dic nam I S[I] J S[J]
  154.         2 index 1 index gt { % swap them
  155.            4 index 2 index 4 index put 
  156.            4 index 4 index 2 index put
  157.            3 1 roll
  158.         } if
  159.         pop pop
  160.       } for
  161.       pop pop
  162.     } for
  163.   } ifelse
  164. } bind def
  165.  
  166. % string:prefix dict:which unprint
  167. /unprint {
  168.   HSdnames % pre dic nam
  169. % compute the maximum length
  170.   0 1 index { % pre dic nam maxlen nam[I]
  171.     length 2 copy lt { exch } if pop
  172.   } forall
  173. % Print out all the items, stack: pre dic nam maxlen
  174.   (\n) print  
  175.   exch { % pre dic maxlen nam[I]
  176. % no prefix yet, -> flush right
  177.     3 index length 0 eq {
  178.       dup length 2 index exch sub HSpindent
  179.     }{
  180.       3 index print (/) print
  181.     } ifelse 
  182. % print the name
  183.     dup print
  184. % prefix: fill up with blanks 
  185.     3 index length 0 ne {
  186.       dup length 2 index exch sub HSpindent
  187.     } if
  188. % now print the item itself, stack: pre dic maxlen nam[I]
  189.     2 index 1 index cvn get dup type % stack: pre dic maxlen nam[i] item typ 
  190. % Dict-Syntax
  191.     dup /dicttype eq { pop % stack: pre dic maxlen nam[i] item
  192.       ( ) print dup HScvs print
  193.       4 index length 0 eq { % brand new prefix
  194.         2 index string 0 1 5 index 1 sub { 1 index exch 32 put } for
  195.         dup 4 index 4 index length sub 5 -1 roll putinterval
  196.       }{
  197.         4 index length 1 add 2 index length add string
  198.         dup 0 7 index putinterval
  199.         dup 6 index length (/) putinterval
  200.         dup 6 index length 1 add 5 -1 roll putinterval
  201.       } ifelse
  202.       exch unprint
  203.     }{
  204.       3 -1 roll pop % tack: pre dic maxlen item typ
  205. % Array-Syntax
  206.       dup /arraytype eq { pop % stack: pre dic maxlen item
  207.         3 index length dup 0 ne { 1 add } if 2 index add 
  208.         exch HSaprint
  209.       }{ pop
  210.         ( ) print
  211.         HScvs print
  212.         (\n) print
  213.       } ifelse
  214.     } ifelse
  215.   } forall
  216.   pop pop length -1 eq { (\n) print } if
  217. } bind def
  218.  
  219. /currentpagedevice where { % check for currentpagedevice
  220.    /currentpagedevice get exec () exch unprint
  221. } if
  222.